﻿@{
    ViewBag.Title = "ThemBanTin";
    Layout = "~/Views/Shared/_blueWhaleLayout.cshtml";
}

<div id="main" class="grid_12">
    <!--  start page-heading -->

    <div id="page-heading" class="box round first grid">
        <h2>Thêm Tin Tức</h2>
    <!-- end page-heading -->
    <div class="block">
       <table>
           <tr>
                <th>Tiêu đề</th>
                <td><input type="text" id="TieuDe" /></td>
            </tr>
           <tr><th>Nội dung</th></tr>
            <tr>
               <th></th>
               <td>
                   <textarea id="NoiDung" name="NoiDung" rows="15" cols="80" style="width:80%;"></textarea>
               </td>
            </tr>           
           <tr>
               <th></th>
               <td>
                   <br />
                   <select id="quyentruycap" name="quyentruycap">
                       <option value="1">Giảng Viên</option>
                       <option value="2">Sinh Viên</option>
                   </select>
               </td>
           </tr>
           <tr>
               <th></th><td><input type="button" id="ThemBanTin" value="Thêm" style="width:100px;padding:5px;float: right;margin-right: 200px;margin-bottom: 30px;"/></td>        
           </tr>
       </table>
    </div>
</div>
</div>

<div class="clear">&nbsp;</div>
<script type="text/javascript">
    var editor=CKEDITOR.replace('NoiDung');
</script>

<script>
    $(document).ready(function () {
        $('#ThemBanTin').click(function () {
            var TieuDe = $("#TieuDe").val();
            //var MoTa = $('#MoTa').val();
            var NoiDung = editor.getData();
            var quyentruycap = $('#quyentruycap').val();
            //alert(TenDeTai + "MoTa:" + MoTa);
            if (TieuDe.trim().length < 1 || NoiDung.trim().length < 1) {
                alert("Tiêu đề bản tin và nội dung không được rỗng!");
                return;
            }
            else {
                $.post("/BanTinGiaoVu/ThemBanTin", { tieuDe: TieuDe, noiDung: NoiDung,quyen:quyentruycap }, function (data) {
                    alert(data.message);
                    if (data.success == true) {
                        //window.location = "/GiangVienClient/DeTai";
                    }
                });
            }
        });        
    });
</script>